<!DCOTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>指标管理</title>
        <link rel="stylesheet" href="/css/theme/font-awesome.min.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/bootstrap.min.css" type="text/css" />
        <link rel="stylesheet" href="/javascript/theme/libs/jquery-easyui-1.4/themes/default/easyui.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/App.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/custom.css" type="text/css" />
        <link rel="stylesheet" href="/css/theme/report/stylesheets/report.css" type="text/css" />
        <script src="/javascript/theme/libs/jquery-1.9.1.min.js"></script>
        <script src="/javascript/theme/libs/jquery-easyui-1.4/jquery.easyui.min.js"></script>
        <script src="/javascript/theme/libs/bootstrap.min.js"></script>
        <script src="/javascript/theme/App.js"></script>
        <script type="text/javascript" src="/javascript/My97DatePicker/WdatePicker.js"></script>
        <script type="text/javascript" src="/javascript/report/FusionCharts.js"></script>
        
        <style type="text/css">
            .alink {
            text-decoration:underline;
            color:#0000CC;
            }
            .alinkClicked {
            color:#0000CC;
            }
            #cates,#locals,#cateClean,#localClean{
            display:none;
            }
            .table tbody>tr>td {
            word-break: break-all;
            word-wrap: break-word;         
            vertical-align: middle;         
            }
        </style>
    </head>

    <body>
    <div id="content" style="OVERFLOW-X:yes;OVERFLOW-Y:auto">
    <!-- 添加 -->
         <div class="mail" id="indexsend" style="display:none;padding: 10px 10px 10px 10px;height:350px;">
            <div class="mail-title">添加数据<span><a href="javascript:void(0);" class="close-mail" onclick="closethis()" style="padding-left: 5px;padding-top: 5px;">关闭</a></span></div>
               
                <div class="form-group" style="padding-left: 50px;padding-top: 30px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;margin-left: -17px;">指标英文名：</label>
                    <div class="col-md-2">
                      <input style="width:200px" type="text" id="indexName1" name="indexName1" class="form-control"/>
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 50px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;margin-left: -17px;">指标中文名：</label>
                    <div class="col-md-2">
                    <input style="width:200px" type="text" id="indexInfo1" name="indexInfo1" class="form-control"/>
                    </div>
                </div>
                 </br>
                  <div class="form-group" style="padding-left: 49px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">一级类别：</label>
                    <div class="col-md-2">
					<input type="hidden" id="alltype" value="全部">
							<select class="easyui-combobox combobox-f combo-f textbox-f" id="cate1" value="全部" data-options="valueField: 'value',textField: 'value'" style="width: 200px; height: 25px; display: none;" textboxname="product" comboname="product">
			    				  #foreach($rs in $cate1List)		
			    								<option value="$!rs" #if($velocityCount==1)selected #end>$!rs</option>
												
								 #end
					        </select>					
				</div>
			        
                </div>
                </br>
                 <div class="form-group" style="padding-left: 49px;padding-top: 14px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">二级类别：</label>
                    <div class="col-md-2">
					<input type="hidden" id="alltype" value="全部">
							<select class="easyui-combobox combobox-f combo-f textbox-f" id="cate2" value="全部" data-options="valueField: 'value',textField: 'value'" style="width: 200px; height: 25px; display: none;" textboxname="product" comboname="product">
			    				  #foreach($rs in $cate2List)		
			    								<option value="$!rs" #if($velocityCount==1)selected #end>$!rs</option>												
								 #end
					        </select>					
				</div>
			                   
                   
                </div>
                </br>
                <div class="form-group" style="padding-left: 49px;padding-top: 14px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">指标类型：</label>
                    <div class="col-md-2">
					<input type="hidden" id="alltype" value="全部">
							<select class="easyui-combobox combobox-f combo-f textbox-f" id="indexType1" value="全部" data-options="valueField: 'value',textField: 'value'" style="width: 200px; height: 25px; display: none;" textboxname="product" comboname="product">
			    				 #foreach($rs in $indexTypeList)		
			    								<option value="$!rs" #if($velocityCount==1)selected #end>$!rs</option>												
								 #end
					        </select>					
				</div>
			                   
                    
                </div>
                </br>
                <div class="form-group" style="padding-left: 49px;padding-top: 14px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">计算公式：</label>
                    <div class="col-md-2">
                      <input style="width:200px" type="text" id="indexRule1" name="indexRule1" class="form-control"/>
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 48px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：</label>
                    <div class="col-md-2">
                      <textarea id="remark1" class="form-control" rows="3" style="width:250px"></textarea>
                    </div>
                </div>
                </br>
                </br>
                <div class="form-group" style="padding-left: 250px;padding-top: 40px;">
                    <button type="button" id="subIndex" name ="subIndex" onclick="IndexSubsend()" class="btn btn-info btn-xs">确认添加</button>
                </div>
        </div>
        <div class="panelhidden-bg" id="panelclose"></div>
       
         <!-- 修改 -->
         <div class="mail" id="indexsend1" style="display:none;padding: 10px 10px 10px 10px;height:370px;">
            <div class="mail-title">修改数据<span><a href="javascript:void(0);" class="close-mail" onclick="closethis()" style="padding-left: 5px;padding-top: 5px;">关闭</a></span></div>
                </br>
                <div class="form-group" style="padding-left: 34px;padding-top: 30px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">指标英文名：</label>
                    <div class="col-md-2">
                      <h3 id="indexName2"></h3>
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 34px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">指标中文名：</label>
                    <div class="col-md-2">
                    <h3 id="indexInfo2"></h3>
                    </div>
                </div>
                 </br>
                <div class="form-group" style="padding-left: 50px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">一级类别：</label>
                    <div class="col-md-2">
                      <input type="hidden" id="alltype" value="全部">
							<select class="easyui-combobox combobox-f combo-f textbox-f" id="modify_cate1" value="全部" data-options="valueField: 'value',textField: 'value'" style="width: 200px; height: 25px; display: none;" textboxname="product" comboname="product">
			    				 #foreach($rs in $cate1List)		
			    								<option value="$!rs" >$!rs</option>											
								 #end
					        </select>		
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 50px;padding-top: 14px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">二级类别：</label>
                    <div class="col-md-2">
                      <input type="hidden" id="alltype" value="全部">
							<select class="easyui-combobox combobox-f combo-f textbox-f" id="modify_cate2" value="全部" data-options="valueField: 'value',textField: 'value'" style="width: 200px; height: 25px; display: none;" textboxname="product" comboname="product">
			    				 #foreach($rs in $cate2List)		
			    								<option value="$!rs" >$!rs</option>												
								 #end
					        </select>		
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 50px;padding-top: 14px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">指标类型：</label>
                    <div class="col-md-2">
                      <input type="hidden" id="alltype" value="全部">
							<select class="easyui-combobox combobox-f combo-f textbox-f" id="modify_indexType" value="全部" data-options="valueField: 'value',textField: 'value'" style="width: 200px; height: 25px; display: none;" textboxname="product" comboname="product">
			    				 #foreach($rs in $indexTypeList)		
			    								<option value="$!rs" >$!rs</option>												
								 #end
					        </select>		
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 50px;padding-top: 14px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">计算公式：</label>
                    <div class="col-md-2">
                      <input style="width:250px" type="text" id="indexRule2" name="indexRule2" class="form-control"/>
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 48px;padding-top: 10px;">
                    <label class="col-md-2" style="font-size: 16px;color: #000000;">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：</label>
                    <div class="col-md-2">
                      <textarea id="remark2" class="form-control" rows="3" style="width:250px"></textarea>
                    </div>
                </div>
                </br>
                <div class="form-group" style="padding-left: 240px;padding-top: 50px;">
                    <button type="button" id="subIndex" name ="subIndex" onclick="sendModify()" class="btn btn-info btn-xs">确认修改</button>
                </div>
        </div>
        
        
    
        <div id="content-container">
            <form action="/indexManager/search" class="form-horizontal" name="searchform" role="form" method="post">
            <div class="portlet">
                <div class="portlet-header">
                    <h3>
                          <i class="fa fa-tasks"></i>
                                                                                           指标管理&nbsp;&nbsp;&nbsp;                                                                                    
                     </h3>
                     
                </div>

            <div class="portlet-content">
  
                <div class="form-group">
                                                           
                          
                        <div class="form-group" id="selectcont2" style="margin-top: 15px;">
						    <label class="col-md-2">&nbsp;&nbsp;指标英文名: 
						    </label>
						    <div class="col-md-2">
						    <input type="text" class="form-control" style="width:200px" name="indexName"  #if($indexInfo1!="")disabled#end id="indexName" rename="指标英文名" value="$!indexName1">
						    </div>&nbsp;
						    <input type="radio" id="selectEnglish" name="selectcontent" value="clicktagname" checked="checked" >
						</div>
						<div class="form-group" id="selectcont3" style="margin-top: 10px;">
						    <label class="col-md-2">&nbsp;&nbsp;指标中文名: 
						    </label>
						    <div class="col-md-2">
						    <input type="text" class="form-control" style="width:200px" name="indexInfo" id="indexInfo" rename="指标中文名" #if($indexInfo1=="")disabled#end value="$!indexInfo1">
						    </div>&nbsp;
						    <input type="radio" id="selectChiness" name="selectcontent" value="sourcename" #if($indexInfo1!="") checked="checked" #end>
						    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						    <input type="button" class="btn btn-primary btn-xs" id="search_button" onclick="searchdata()" value="查询">  
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="button" class="btn btn-primary btn-xs" id="IndexSubsend" onclick="indexsub()" value="添加">                                        

                </div>

                <div class="form-group">
                     <div > &nbsp;&nbsp;&nbsp;&nbsp;</div>
                </div>
               

                <textarea style="width:100px;height:20px"  hidden="hidden"  name="selecttype" id="selecttype" value="$!{selecttype}" >$!{selecttype}</textarea>  

              </form>
            </div><!--portlet-content-->
            </div><!--portlet-->
#if($rsList)
          <div class="portlet">
    <div class="portlet-header">
        <h3>
            <i class="fa fa-hand-o-up"></i>
            查询结果
        </h3>
        <input type='hidden' id='curPage' #if($pageindex) value="$pageindex" #else value="0" #end/>
    </div>
        <div class="portlet-content">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover" id="wordtable" data-provide="datatable" data-display-rows="20" >
                    <thead>
                        <tr>                         
                            <th  style="text-align:center;">指标英文名</th>
                            <th  style="text-align:center;">指标中文名</th>
                            <th  style="text-align:center;">一级类别</th>
                            <th  style="text-align:center;">二级类别</th>
                            <th  style="text-align:center;">指标类型</th>
                            <th  style="text-align:center;">计算规则</th>    
                            <th  style="text-align:center;">备注</th>   
                            <th  style="text-align:center;"></th>             
                        </tr>
                    </thead>
                    
                    <tbody>
                        #foreach($rs in $rsList)
                            <tr  align="center" >                                               
                                <td style="text-align:center;width:220px;">$!rs.indexName</td>
                                <td style="text-align:center;width:130px;">$!rs.indexInfo</td>
                                <td style="text-align:center;width:80px;">$!rs.cate1</td>
                                <td style="text-align:center;width:80px;">$!rs.cate2</td>
                                <td style="text-align:center;width:80px;">$!rs.indexType</td> 
                                <td style="text-align:center;width:150px;">$!rs.countRule</td>
                                <td style="text-align:center;width:200px;">$!rs.remark</td>
                                <td style="text-align:center;width:50px;"><input type="hidden" value="$!rs.cate1"/><input type="hidden" value="$!rs.cate2"/><input type="button" class="btn btn-primary btn-xs" onclick="modifyData(this)" value="修改"></td>
                            </tr>
                        #end												
                    </tbody>
                </table>
                <div class="row dt-rb">
                            #parse("/views/default/newpage.vm")                                               
                                 #pagenew($pList "/indexManager/search?#page#&$paramurl")
                                 
                            
                </div>	
            </div>
        </div>
</div>
#end


</div>



<script >
    var countRuleInnit = "";
    var remarkInnit = "";
    //设置修改时的数据
	function modifyData(obj){
	
		var $tds = $(obj).parent().parent().children();
		var indexName = $tds.eq(0).text();
		var indexInfo = $tds.eq(1).text();
		var cate1 = $(obj).prev().prev().get(0).value;
		var cate2 = $(obj).prev().get(0).value;
		var indexType = $tds.eq(4).text();
		var countRule = $tds.eq(5).text();
		var remark = $tds.eq(6).text();	
		//修改前的数据
		cate1Innit = cate1;
		cate2Innit = cate2;
		indexTypeInnit = indexType;
		countRuleInnit = countRule;
		remarkInnit = remark;
		
		//设置下拉框的selected
		
		$("#modify_cate1").combobox('select',cate1);
		$("#modify_cate2").combobox('select',cate2);
		$("#modify_indexType").combobox('select',indexType);
		
		$("#indexName2").text(indexName);
		$("#indexInfo2").text(indexInfo);		
		$("#indexRule2").val(countRule);
		$("#remark2").text(remark);
		$('#indexsend1').show();
        $('#panelclose').show();
	}
    
    function changeSelected(obj,text){
    	var $option = obj.children();
        var i = 0;
    	$.each($option,function(index,element){
    		 if($(element).text()==text){	 
    			 return false;
    		 }
    		 i++;
    	});
    	obj.children().eq(i).remove();
    }

    function deleteData(obj){
    		
    	var $tds = $(obj).parent().parent().children();
		var indexName = $tds.eq(0).text();
    	//表格行数，判断表格的数据是否只有一条
    	var rows = $("#wordtable").children().size();
    	jQuery.ajax({
            url:"$!{__beat.server.contextPath}/indexManager/modify/delete",
            type:"post",
            async:true,
            data:{"indexName":indexName},
                   success:function(data){
                       if(data == "error"){
                           alert("操作失败！");
                       }else{
                    	   var paramurl2 ="&indexInfo="+$("#indexInfo").val()+"&indexName="+$("#indexName").val();                    	   
                           alert("操作成功！");
                           if(rows==2 && ($('#curPage').val()==getEndPage())&&getEndPage()>1){
                        	   var pageindex = $('#curPage').val()-1;
                        	   window.location.href="$!{__beat.server.contextPath}/indexManager/search?pageindex=" +pageindex+paramurl2;
                           } else{
                        	   
                               window.location.href="$!{__beat.server.contextPath}/indexManager/search?pageindex=" + $('#curPage').val()+paramurl2;                                       
                           }
                       }
                   }
               });
    } 

function searchdata(){
	var indexName = $("#indexName").val();
	var indexInfo = $("#indexInfo").val();
	if(indexName == "" && indexInfo == ""){
		alert("请输入搜索内容！");
		return;
	} 
	searchform.submit();  
	if(indexInfo!=""){
		document.getElementById("indexName").disabled=true;
	}
}

 function closethis(){
    $('.mail').hide();
    $('.panelhidden-bg').hide();
}
   function IndexSubsend(){
    
		var indexName = $("#indexName1").val();
	    var indexInfo = $("#indexInfo1").val();
	    var cate1 = $("#cate1").next().children().eq(2).val();
	    var cate2 = $("#cate2").next().children().eq(2).val();
	    var indexType = $("#indexType1").next().children().eq(2).val();
		var countRule = $("#indexRule1").val();
		var remark = $("#remark1").val();	
	    
	    if(indexName==""||indexInfo==""){
			alert("请输入指标英文名和中文名！");
			return;
		}else if(cate1==""){
			alert("请选择或者输入一级类别");
			return;
		}else if(cate2==""){
			alert("请选择或者输入二级类别");
			return;
		} else if(indexType==""){
			alert("请选择或者输入指标类型");
			return;
		}  
		
	     jQuery.ajax({
	        url:"$!{__beat.server.contextPath}/indexManager/add",
	        type:"post",
	        async:true,
	        data:{"indexName":indexName,"indexInfo":indexInfo,"cate1":cate1,"cate2":cate2,"indexType":indexType,"countRule":countRule,"remark":remark},
	               success:function(data){
	                   if(data == "error"){
	                       alert("操作失败！");
	                   }else if(data == "success"){
	                       var paramurl2 ="&indexName="+indexName;
	                       alert("添加成功！");
                           $('#indexsend').hide();
                           $('.panelhidden-bg').hide();
	                     //  window.location.href="$!{__beat.server.contextPath}/indexManager/search?pageindex=" + $('#curPage').val()+paramurl2;             
	                   }else{
	                	    alert("该指标已经存在！");
	                   }
	               
		}
	           }); 
	     
} 
  
function sendModify(){
	//alert($("#indexInfo").val());
	var indexInfo = $("#indexInfo2").text();
	var cate1 = $("#modify_cate1").next().children().eq(2).get(0).value;
	var cate2 = $("#modify_cate2").next().children().eq(2).get(0).value;
	var indexType = $("#modify_indexType").next().children().eq(2).get(0).value;
	var countRule = $("#indexRule2").val();
	var remark = $("#remark2").val();	
	var indexName = $("#indexName2").text();
   
	if(countRule==countRuleInnit && remark==remarkInnit && cate1==cate1Innit && cate2==cate2Innit && indexType==indexTypeInnit){		
		alert("您没有修改任何信息");
		return;
	}
	
	jQuery.ajax({
        url:"$!{__beat.server.contextPath}/indexManager/modify/update",
        type:"post",
        async:true,
        data:{"indexName":indexName,"cate1":cate1,"cate2":cate2,"indexType":indexType,"countRule":countRule,"remark":remark},
               success:function(data){
            	   $('#indexsend1').hide();
                   $('.panelhidden-bg').hide();
                   if(data == "error"){
                       alert("操作失败！");
                   }else{
                       var paramurl2 ="&indexInfo="+$("#indexInfo").val()+"&indexName="+$("#indexName").val();                      
                       alert("修改成功");
                       window.location.href="$!{__beat.server.contextPath}/indexManager/search?pageindex=" + $('#curPage').val()+paramurl2;             
                   }
               }
           });
      
    
} 

function getEndPage(){
	var $li = $(".pagination li");
	var endPage = 1;
	for(var i=$li.size()-1;i>=0;i--){
		endPage = parseInt($li.eq(i).text());
		if(!isNaN(endPage)){
			return endPage;
		}
	}
	return endPage;
	
}

function indexsub(){
	$("#indexName1").val("");
    $("#indexInfo1").val("");
	$("#indexRule1").val("");
	$("#remark1").val("");	
    $('#indexsend').show();
    $('#panelclose').show();    
} 

$("#selectEnglish").click(function(){
	$("#indexInfo").val("");
	$("#indexName").val("");
	document.getElementById("indexInfo").disabled=true;
	document.getElementById("indexName").disabled=false;
});
$("#selectChiness").click(function(){
	$("#indexInfo").val("");
	$("#indexName").val("");
	document.getElementById("indexName").disabled=true;
	document.getElementById("indexInfo").disabled=false;
});
 
</script>
</body>
</html>